﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inaction.Database
{
    public class DesignTimeProvider
    {
        private DesignTimeProvider()
        {
            if (string.IsNullOrEmpty(Inaction.AppConfig.Instance.ConnectionString))
            {
                new DbConnecteForm().ShowDialog();
            }
            Provider = new Inaction.Database.DbProvider();
            Inaction.DbProvider.SetInstance(Provider);
        }

        public static void ConnecteDb()
        {
            new DbConnecteForm().ShowDialog();
            instance = new DesignTimeProvider();
        }

        private static DesignTimeProvider instance = null;
        public Inaction.Database.DbProvider Provider { get; private set; }
        public static DesignTimeProvider Instance
        {
            get
            {
                if (instance == null || string.IsNullOrEmpty(instance.Provider.ConnectionString))
                {
                    instance = new DesignTimeProvider();
                }
                return instance;
            }
        }
    }
}
